package day06;
import java.util.Arrays;
//数组的演示
public class ArrayDemo {
    public static void main(String[] args) {

/*
        int[] a={10,20,30,40,50};
        int[] b=new int[6];
        System.arraycopy(a,2,b,0,3);//30,40,50,0,0,0
        //a:原数组
        //srcPos:原数组的起始下标
        //b:目标数组
        //destPos:目标数组的起始下标
        //length:要复制的元素个数
        for (int i=0;i<b.length;i++){
            System.out.println(b[i]);
//            System.arraycopy(b,1,a,2,3);
        }
        System.arraycopy(a,1,b,3,3);//30,40,50,20,30,40
        for (int i=0;i<b.length;i++){
            System.out.println(b[i]);
        }

 */




        int[] a={10,20,30,40,50};
       a=Arrays.copyOf(a,a.length+3);//a数组的扩容10,20,30,40,50,0,0,0
       for (int i=0;i<a.length;i++){
            System.out.println(a[i]);
        }
        int[] b=Arrays.copyOf(a,4);//10,20,30,40
        for (int i=0;i<b.length;i++){
            System.out.println(b[i]);
        }








    }
}
